package com.example.service.impl;

import com.example.annotations.Service;
import com.example.service.AppService;
import com.example.utils.ClazzScanUtils;
import com.example.utils.ObjectMaps;
import com.example.utils.PropertiesUtils;

import java.util.List;

/**
 * @Classname AppServiceImpl
 * @Description TODO
 * @Date 2022/8/9 15:36
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@Service
public class AppServiceImpl implements AppService {

    @Override
    public List<Class<?>> getClassList() {
        return ClazzScanUtils.getClassPaths();
    }

    @Override
    public Object getObjectByClass(Class<?> cls) {
       return ObjectMaps.getObjectByClass(cls);
    }

    @Override
    public Object getObjectByName(String name) {
        return ObjectMaps.getObjectByName(name);
    }

    @Override
    public String getPropertiesByKey(String key) {
        return PropertiesUtils.getProperty(key);
    }

    @Override
    public void putObjectByClass(Class<?> cls, Object object) {
        if(object==null){
            return;
        }
        if(ObjectMaps.getObjectByClass(cls)!=null){
            System.out.println(cls.getName()+"已存在，操作被拒绝");
            return;
        }
        ObjectMaps.setAutuWirdemap(cls.getName(),object);
    }
}
